package com.lala.service.impl;

import com.lala.entity.ClientComment;
import com.lala.dao.ClientCommentDao;
import com.lala.service.ClientCommentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * (ClientComment)表服务实现类
 *
 * @author makejava
 * @since 2020-03-25 21:10:40
 */
@Service("clientCommentService")
public class ClientCommentServiceImpl implements ClientCommentService {
    @Resource
    private ClientCommentDao clientCommentDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public ClientComment queryById(Integer id) {
        return this.clientCommentDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<ClientComment> queryAllByLimit(int offset, int limit) {
        return this.clientCommentDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param clientComment 实例对象
     * @return 实例对象
     */
    @Override
    public ClientComment insert(ClientComment clientComment) {
        this.clientCommentDao.insert(clientComment);
        return clientComment;
    }

    /**
     * 修改数据
     *
     * @param clientComment 实例对象
     * @return 实例对象
     */
    @Override
    public ClientComment update(ClientComment clientComment) {
        this.clientCommentDao.update(clientComment);
        return this.queryById(clientComment.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.clientCommentDao.deleteById(id) > 0;
    }

    @Override
    public List<Map> getComment(Integer clientId) {
        return clientCommentDao.getComment(clientId);
    }

    @Override
    public List<Map> allComment(Integer clientId) {
        return clientCommentDao.allComment(clientId);
    }

    @Override
    public void save(ClientComment comment) {
        clientCommentDao.insert(comment);
    }
}